home *** CD-ROM | disk | FTP | other *** search
- unit Capture3U;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, ExtDlgs;
-
- type
- TForm1 = class(TForm)
- Img: TImage;
- SaveDlg: TSavePictureDialog;
- LoadDlg: TOpenPictureDialog;
- Panel1: TPanel;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Button1Click(Sender: TObject);
- const
- NumColors = 256;
- var
- R: TRect;
- C: TCanvas;
- P: TMaxLogPalette;
- begin
- R := Img.BoundsRect;
- C := TCanvas.Create;
- C.Handle := GetDC(HWnd_Desktop);
- try
- Img.Canvas.CopyRect(R, C, R);
- P.palVersion := $300;
- P.palNumEntries := NumColors;
- GetSystemPaletteEntries(C.Handle, 0, NumColors, P.palPalEntry);
- Img.Picture.Bitmap.Palette := CreatePalette(PLogPalette(@P)^);
- finally
- ReleaseDC(HWnd_Desktop, C.Handle);
- C.Free;
- end;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- if SaveDlg.Execute then
- Img.Picture.Bitmap.SaveToFile(SaveDlg.FileName)
- end;
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- if LoadDlg.Execute then
- Img.Picture.Bitmap.LoadFromFile(LoadDlg.FileName)
- end;
-
- end.
-